151
Advanced Graphics
151
STEP 4 continued (1)
Get the data from the website.
Dim myURL As String
Dim Days As Long
Days = CLng(Format(Now, “YYYYMMDD”)) - CLng(thisWsGraphs.Cells(23, 2))
‘ get the file of data from the web
a = thisWsGraphs.Cells(23, 2)
If CLng(Format(Now, “YYYYMMDD”)) > 20200513 Then
a = 1
End If
If Days > 0 Then
myURL = “https://usafactsstatic.blob.core.windows.net/public/data/covid-19/
covid_confirmed_usafacts.csv”
Dim HttpReq As Object
Set HttpReq = CreateObject(“Microsoft.XMLHTTP”)
‘ HttpReq.Open “GET”, myURL, False, “username”, “password”
HttpReq.Open “GET”, myURL, False, “”, “”
HttpReq.send
myURL = HttpReq.responseBody
If HttpReq.Status = 200 Then
Set oStrm = CreateObject(“ADODB.Stream”)
oStrm.Open
oStrm.Type = 1
oStrm.Write HttpReq.responseBody
oStrm.SaveToFile filepath1, 2 ‘ 1 = no overwrite, 2 = overwrite
oStrm.Close
End If
End If
If Days > 0 Then
myURL = “https://usafactsstatic.blob.core.windows.net/public/data/covid-19/
covid_deaths_usafacts.csv”
Set HttpReq = CreateObject(“Microsoft.XMLHTTP”)
‘ HttpReq.Open “GET”, myURL, False, “username”, “password”
HttpReq.Open “GET”, myURL, False, “”, “”
HttpReq.send
myURL = HttpReq.responseBody
If HttpReq.Status = 200 Then
Set oStrm = CreateObject(“ADODB.Stream”)
oStrm.Open
oStrm.Type = 1
oStrm.Write HttpReq.responseBody
oStrm.SaveToFile filepath2, 2 ‘ 1 = no overwrite, 2 = overwrite
oStrm.Close
End If
End If